const express = require('express')
const router = express.Router()
const { DataChatsController } = require('../controller/chats')
const { SysUserController } = require('../controller/sys_user')
const authMiddleware = require('../middleware/auth')

router.get(
  '/v1/chats/unread',
  authMiddleware,
  DataChatsController.unreadControl
) // 未读消息数量
router.post(
  '/v1/chats/message',
  authMiddleware,
  DataChatsController.messageList
)
router.post(
  '/v1/chats/private/detail',
  authMiddleware,
  DataChatsController.getPrivateDetail
)
router.post(
  '/v1/chats/private/saveMsg',
  authMiddleware,
  DataChatsController.saveMsg
)
router.post(
  '/v1/chats/find_people',
  authMiddleware,
  SysUserController.findUserByName
)
router.get('/v1/chats/user_info', authMiddleware, SysUserController.getUserInfo) // 获取用户资料
router.post('/v1/chats/is_friend', authMiddleware, DataChatsController.isFriend) // 是否是好友
router.post(
  '/v1/chats/insert/friends',
  authMiddleware,
  DataChatsController.insertNewFriends
) // 添加我的新好友通知
router.get(
  '/v1/chats/get/newfriends',
  authMiddleware,
  DataChatsController.getNewFriends
) // 获取新朋友通知
router.get(
  '/v1/chats/get/friends',
  authMiddleware,
  DataChatsController.getFriends
) // 获取朋友列表
router.post(
  '/v1/chats/friend/chatList',
  authMiddleware,
  DataChatsController.friendChatList
) // 获取好友聊天相关内容
router.post(
  '/v1/chats/friend/read',
  authMiddleware,
  DataChatsController.clearUnread
) // 获取好友聊天相关内容
router.post(
  '/v1/chats/be_friend',
  authMiddleware,
  DataChatsController.agreeBeFriend
) // 加为好友
router.post(
  '/v1/chats/friend/disagree',
  authMiddleware,
  DataChatsController.disagreeBeFriend
) // 拒绝加为好友
router.delete(
  '/v1/chats/friend/delete',
  authMiddleware,
  DataChatsController.deleteFriend
) // 删除好友
router.put(
  '/v1/chats/friend/editAlias',
  authMiddleware,
  DataChatsController.editorRemark
) // 修改备注
router.put(
  '/v1/chats/editor_remark',
  authMiddleware,
  DataChatsController.editorRemark
) // 修改备注
router.post(
  '/v1/chats/group/findByName',
  authMiddleware,
  DataChatsController.findGroup
) // 查找群
router.post(
  '/v1/chats/group/create',
  authMiddleware,
  DataChatsController.createGroup
) // 建群
router.post(
  '/v1/chats/group/edit',
  authMiddleware,
  DataChatsController.editGroup
) // 编辑群
router.post(
  '/v1/chats/group/join',
  authMiddleware,
  DataChatsController.joinGroup
) // 加入群
router.post(
  '/v1/chats/group/exit',
  authMiddleware,
  DataChatsController.exitGroup
) // 退群
router.post(
  '/v1/chats/group/chatList',
  authMiddleware,
  DataChatsController.groupChatList
) // 获取群相关内容
router.post(
  '/v1/chats/group/chat/save',
  authMiddleware,
  DataChatsController.saveGroupChat
) // 保存群信息
router.get(
  '/v1/chats/group/isIn',
  authMiddleware,
  DataChatsController.isInGroup
) // 看某个用户是否在某个群中(根据返回的数组长度是不是为零就知道)
router.get(
  '/v1/chats/group/getInfo',
  authMiddleware,
  DataChatsController.getGroupInfo
) //获取群资料
router.get(
  '/v1/chats/get/groups',
  authMiddleware,
  DataChatsController.getGroups
) //
router.post(
  '/v1/chats/search',
  authMiddleware,
  DataChatsController.searchUserOrGroup
) //
router.post(
  '/v1/chats/newFriend/unread/clear',
  authMiddleware,
  DataChatsController.clearNewFriendUnread
) //
module.exports = router
